<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit|ie-comp|ie-stand" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
 <link href="${pageContext.request.contextPath}/assets/css/bootstrap.min.css" rel="stylesheet" />
        <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css"/>       
        <link href="${pageContext.request.contextPath}/assets/css/codemirror.css" rel="stylesheet" />
        <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/ace.min.css" />
        <link rel="stylesheet" href="${pageContext.request.contextPath}/font/css/font-awesome.min.css" />
        <!--[if lte IE 8]>
		  <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
		<![endif]-->
		<script src="${pageContext.request.contextPath}/js/jquery-1.9.1.min.js"></script>
        <script src="${pageContext.request.contextPath}/assets/js/bootstrap.min.js"></script>
		<script src="${pageContext.request.contextPath}/assets/js/typeahead-bs2.min.js"></script>           	
		<script src="${pageContext.request.contextPath}/assets/js/jquery.dataTables.min.js"></script>
		<script src="${pageContext.request.contextPath}/assets/js/jquery.dataTables.bootstrap.js"></script>
        <script src="${pageContext.request.contextPath}/assets/layer/layer.js" type="text/javascript" ></script>          
        <script src="${pageContext.request.contextPath}/assets/laydate/laydate.js" type="text/javascript"></script>
        <script language="javascript" type="text/javascript" src="${pageContext.request.contextPath}/My97DatePicker/WdatePicker.js"></script>
<title>投诉</title>

<script type="text/javascript">
		function submitForm()
		{
			document.getElementById("myForm").submit();
		}
		
		$(function(){
			
			 $("input[name='typeId']").click(function(){
		            $("#checkAll").prop("checked",$("input[name='typeId']").length == $("input[name='typeId']:checked").length ? true : false);
		        });
			
			$("#checkAll").click(
			  function(){
			   $("input[name='typeId']").prop("checked",this.checked);
			  }
			);
			
			/**批量删除**/
			$("#deleteByGroup").click(function(){
				var typeId="";
				var judgement=false;
				if($("input[name='typeId']:checked").length)
					{
					layer.confirm('确认要删除吗？',function(index){
						$("input[name='typeId']:checked").each(function(){
							judgement=false;
							if($(this).parents("tr").find(".complian_adminer").attr("id")!=$("#administrator_id").html()&&$(this).parents("tr").find(".complian_adminer").attr("id")!="")
							{
							 	layer.alert("所选投诉已有其他管理员跟进，请重新选择",{
					               title: '提示框',				
								icon:1,		
								  });
								return false;
							}
							else
							{
								judgement=true;
								typeId=typeId+$(this).parents("tr").find(".type_id").html()+";";
							}
						});
						if(judgement){
							$("#del_list").val(typeId);
							$("#delopr").val("del");
							//alert($("#del_list").val());
							//alert($("#delopr").val());
							$("#delForm").submit();
						}
						layer.close(index);	
					});
					}
				else
					{
					layer.alert("你未选中任何项",{
			               title: '提示框',				
						icon:1,		
						  });				
					}
				//alert(typeId);
			});
		});
		
		function checkMsg()
		{
			if($("#updatecomplain").length>0)
			{
				  layer.alert($("#updatecomplain").html(),{
	               title: '提示框',				
				icon:1,		
				  });
			}
		}
		
		//<c:if test="${complain.is_solve==0 }">style="background-color:red; "</c:if> <c:if test="${complain.is_solve==1 }">style="background-color:#11C1FF; "</c:if> <c:if test="${complain.is_solve==2 }">style="background-color:#83E90E; "</c:if>
	</script>
	

</head>

<body onload="checkMsg();">
<div class="margin clearfix">
 <div class="Guestbook_style">
    <div class="border clearfix">
       <span class="l_f">
        <a href="javascript:ovid()" class="btn btn-danger" id="deleteByGroup" ><i class="fa fa-trash"></i>&nbsp;批量删除</a>
        <a href="complainServlet?is_solve=0" class="btn btn-yellow"><i class="fa fa-times"></i>&nbsp;未处理</a>
        <a href="complainServlet?is_solve=1" class="btn btn-sm btn-primary"><i class="fa fa-edit bigger-120"></i>&nbsp;处理中</a>
        <a href="complainServlet?is_solve=2" class="btn btn-success"><i class="fa fa-check"></i>&nbsp;已处理</a>
      	<a href="complainServlet?opr=list" class="btn btn-success"><i class="fa fa-feed"></i>&nbsp;全部</a>
       </span>
       <span class="r_f">共：<b>${complainlist.size() }</b>条记录</span>
     </div>
    <!--投诉列表-->
    <div class="Guestbook_list">
      <table class="table table-striped table-bordered table-hover" id="sample-table">
      <thead>
		 <tr >
          <th width="25"><label><input type="checkbox" class="ace" id="checkAll" /><span class="lbl" ></span></label></th>
          <th width="80">ID</th>
          <th width="150px">投诉内容</th>
          <th width="">投诉人</th>
          <th width="">处理进度</th>
          <th width="">处理人</th>
          <th width="150px">处理结果</th>
          <th width="200px">投诉时间</th>
          <th width="200px">解决时间</th>
          <th width="70">状态</th>                
          <th width="250">操作</th>
          </tr>
      </thead>
	<tbody>
		 <c:if test="${complainlist!= null && complainlist.size() > 0}">
          	<c:forEach items="${complainlist }" var="complain">
          	<tr >
     			<td ><label><input type="checkbox" class="ace" name="typeId"  /><span class="lbl"></span></label></td>
         		<td class="type_id">${complain.complain_id }</td>
         		<td class="details">${complain.details }</td>
          		<td class="text-l">
          		<span id="cusinfo1" style="display:none;">${opinion.customer.customer_id }</span>
         		<span id="cusinfo2" style="display:none;">${opinion.customer.customer_name }</span>
         		<span id="cusinfo3" style="display:none;">${opinion.customer.eMail }</span>
         		<span id="cusinfo4" style="display:none;">${opinion.customer.telephone }</span>
         		<span id="cusinfo5" style="display:none;">${opinion.customer.realName }</span>
         		<span id="cusinfo6" style="display:none;">${opinion.customer.address }</span>
         		<span id="cusinfo7" style="display:none;">${opinion.customer.credit }</span>
         		<span id="cusinfo8" style="display:none;">${opinion.customer.assetLv.assetLv_name }</span>
          		<a href="javascript:;" onclick="member_show(this)">${complain.customer.customer_name }</a>
          		</td>
          		<td class="is_solve" <c:if test="${complain.is_solve==0 }">style="background-color:#FFFF80; "</c:if> <c:if test="${complain.is_solve==1 }">style="background-color:#1DA8D7; "</c:if> <c:if test="${complain.is_solve==2 }">style="background-color:#73B64D; "</c:if> >
          		<c:if test="${complain.is_solve==0 }">未处理</c:if> 
          		<c:if test="${complain.is_solve==1 }">处理中</c:if> 
          		<c:if test="${complain.is_solve==2 }">已处理</c:if>
          		</td>
          		<td class="complian_adminer" id="${complain.adminer.admin_id }"><u style="cursor:pointer"  class="text-primary" onclick="member_show('张小泉','member-show.html','1031','500','400')">${complain.adminer.admin_name }</u></td>
          		<td class="results">${complain.results }</td>
          		<td>${complain.start_date }</td>
          		<td>${complain.end_date }</td>
          		<td class="td-status"><span class="label label-success radius">未锁定</span></td>
         		<td class="td-manage" class="is_solve" <c:if test="${complain.is_solve==0 }">style="background-color:#FFFF80; "</c:if> <c:if test="${complain.is_solve==1 }">style="background-color:#1DA8D7; "</c:if> <c:if test="${complain.is_solve==2 }">style="background-color:#73B64D; "</c:if> >
	           		<a  onclick="member_stop(this,'10001')"  href="javascript:;" title="未锁定"  class="btn btn-xs btn-success">
	           			<i class="fa fa-check  bigger-120"></i>
	           		</a>  
	        		<c:if test="${complain.is_solve==0 }">
		        		<a id="operation" href="javascript:;" onclick="member_edit(this)" title="受理"   class="btn btn-xs btn-info" >
		        			<i class="fa fa-edit bigger-120"></i>
		        		</a> 
	        		</c:if> 
        	  		<c:if test="${complain.is_solve==1 }">
       	 	  			<a id="operation" href="javascript:;" onclick="member_edit(this)" title="解决"   class="btn btn-xs btn-info" >
		        			<i class="fa fa-edit bigger-120"></i>
		        		</a> 
        	  		</c:if> 
          			<c:if test="${complain.is_solve==2 }">
          				<a id="operation" href="javascript:;"  title="已完成"   class="btn btn-xs btn-info" >
		        			<i class="fa fa-edit bigger-120"></i>
		        		</a> 
          			</c:if>
	        		<a  href="javascript:;"  onclick="member_del(this);" title="删除" class="btn btn-xs btn-warning" >
	        			<i class="fa fa-trash  bigger-120"></i>
	        		</a>
          		</td>
        	</tr> 
          	</c:forEach>
         </c:if> 
        </tbody>
      </table>
    </div>
 </div>
</div>

<!--管理员信息-->
<div style="display: none">
	<span id="administrator_id">${sessionScope.userInfo.admin_id }</span>
</div>

<!--操作信息-->
<div style="display: none">
	<c:if test="${sessionScope.excuteMsg_complain!=null&&sessionScope.excuteMsg_complain.length()>0 }"><span id="updatecomplain">${sessionScope.excuteMsg_complain }</span></c:if>
</div>

<!--批量删除提交-->
<div style="display: none">
	<form action="complainServlet" method="post" id="delForm">
		<input type="hidden" name="opr" id="delopr" />
		<input type="text" id="del_list" name="del_list" />
	</form>
</div>

<!--单个删除提交-->
<div style="display: none">
	<form action="complainServlet" method="post" id="delBySingle">
		<input type="hidden" name="opr" value="del" />
		<input type="hidden" name="complain_id" id="delsingleId" />
	</form>
</div>

<!--客户详情-->
<div id="cusdetails" style="display:none">
<div class="member_show" >
<div class="member_jbxx clearfix" >
<img class="img" src="${pageContext.request.contextPath}/images/user.png" />
  <dl  class="right_xxln">
  <dt><span class="cusinfo2"></span></dt>
  <dd class="" style="margin-left:0">这家伙很懒，什么也没有留下</dd>
  </dl>
</div>
<div class="member_content">
  <ul>
   <li><label class="label_name">会员号：</label><span class="cusinfo1"></span></li>
   <li><label class="label_name">邮箱：</label><span class="cusinfo3"></span></li>
   <li><label class="label_name">手机：</label><span class="cusinfo4"></span></li>
   <li><label class="label_name">真实姓名：</label><span class="cusinfo5"></span></li>
   <li><label class="label_name">地址：</label><span class="cusinfo6"></span></li>
   <li><label class="label_name">信用度：</label><span class="cusinfo7"></span></li>
   <li><label class="label_name">资产等级：</label><span class="cusinfo8"></span></li>
   
  </ul>
</div>
</div>
</div>

<!--添加处理结果-->
<div id="add_ads_style"  style="display:none">
	<form action="complainServlet" method="post" id="updateForm">
  	<input type="hidden" name="is_solve"  id="is_solve"/>
	<input type="hidden" name="complain_id" id="complain_id" />
	<input type="hidden" name="opr" id="opr_update" />
	 	<div class="add_adverts">
		 	<ul>
		  		<li>
		  			<label class="label_name">请填写处理结果：</label>
		  			<span class="cont_style">
		  			<textarea rows="5" cols="50" name="results" id="results"></textarea>
		  			</span>
		  		</li>
		 	</ul>
	 	</div>
	</form>
</div>
</body>
</html>

<script type="text/javascript">
 /*用户-查看*/
function member_show(title,url,id,w,h){
	layer_show(title,url+'#?='+id,w,h);
}

/*投诉-锁定*/
function member_stop(obj,id){
	layer.confirm('确认要锁定吗？',function(index){
		var beforetitle=$(obj).parents("td").find("#operation").attr("title");
		$(obj).parents("tr").find(".ace").prop("checked",false).attr("disabled","disabled");
		$(obj).next().remove();
		$(obj).next().remove();
		$(obj).after('<a id="operation" title="'+beforetitle+'" href="javascript:;"  class="btn btn-xs btn-info" ><i class="fa fa-edit bigger-120"></i></a> <a title="删除" href="javascript:;"  class="btn btn-xs btn-warning" ><i class="fa fa-trash  bigger-120"></i></a>');
		$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs " onClick="member_start(this,id)" href="javascript:;" title="解锁"><i class="fa fa-check  bigger-120"></i></a>');
		$(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已锁定</span>');
		//var $aa=$($(obj).parents("td"));
		$(obj).remove();
		//alert($aa.html());
		layer.msg('已锁定!',{icon: 5,time:1000});
	});
}
//<a title="编辑" onclick="member_edit('550')" href="javascript:;"  class="btn btn-xs btn-info" ><i class="icon-edit bigger-120"></i></a> 
/*投诉-解锁*/
function member_start(obj,id){
	layer.confirm('确认要解锁吗？',function(index){
		var beforetitle=$(obj).parents("td").find("#operation").attr("title");
		$(obj).parents("tr").find(".ace").removeAttr("disabled");
		$(obj).next().remove();
		$(obj).next().remove();
		var beforetitle=$(obj).parents("tr").find(".td-manage").find("#operation").attr("title");
		$(obj).after('<a id="operation" title="'+beforetitle+'" href="javascript:;" onclick="member_edit(this);" class="btn btn-xs btn-info" ><i class="fa fa-edit bigger-120"></i></a> <a title="删除" href="javascript:;"  onclick="member_del(this);" class="btn btn-xs btn-warning" ><i class="fa fa-trash  bigger-120"></i></a>');
		$(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs btn-success" onClick="member_stop(this,id)" href="javascript:;" title="锁定"><i class="fa fa-check  bigger-120"></i></a>');
		$(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">未锁定</span>');
		//var $aa=$($(obj).parents("td"));
		$(obj).remove();
		//alert($aa.html());
		layer.msg('已解锁!',{icon: 6,time:1000});
	});
}

/*******删除单条投诉*********/
function member_del(obj){
	if($(obj).parents("tr").find(".complian_adminer").attr("id")!=$("#administrator_id").html()&&$(obj).parents("tr").find(".complian_adminer").attr("id")!="")
	{
	layer.alert("该投诉已有其他管理员跟进,请选择其他投诉！\r\n",{
        title: '提示框',				
		icon:0,								
  	}); 
	}
	else{
		layer.confirm('确认要删除吗？',function(index){
			$("#delsingleId").val($(obj).parents("tr").find(".type_id").html());
			$("#delBySingle").submit();
			layer.close(index);	
		});
	}
}

/*投诉——修改*/
function member_edit(obj)
{
	if($(obj).parents("tr").find(".complian_adminer").attr("id")!=$("#administrator_id").html()&&$(obj).parents("tr").find(".complian_adminer").attr("id")!="")
		{
		layer.alert("该投诉已有其他管理员跟进,请选择其他投诉！\r\n",{
            title: '提示框',				
			icon:0,								
      	}); 
		}
	else{
		var sss=$(obj).parents("tr").find(".is_solve").html().replace(/\s+/g,"");
		if(sss=="未处理")
			{
				status_edit_recept(obj);
			}
		else
			{
				status_edit_solve(obj);
			}
		}
	}
	
/*投诉——受理*/
function status_edit_recept(obj)
{
	layer.confirm('确认要受理吗？',function(index){
		$("#complain_id").val($(obj).parents("tr").find(".type_id").html());
		$("#is_solve").val(1);
		$("#opr_update").val("update");
		$("#updateForm").submit();
		layer.msg('受理!',{icon: 6,time:1000});
	});
	
}

/*投诉——解决*/
function status_edit_solve(obj)
{
	$("#complain_id").val($(obj).parents("tr").find(".type_id").html());
	$("#is_solve").val(2);
	$("#opr_update").val("update");
	  layer.open({
       type: 1,
       title: '解决投诉',
		maxmin: true, 
		shadeClose: false, //点击遮罩关闭层
       area : ['800px' , ''],
       content:$('#add_ads_style'),
		btn:['提交','取消'],
		yes:function(index,layero){	
		 var num=0;
		 var str="";
   		
         if($("#results").val()=="")
         {
             
        	   layer.alert("处理结果不能为空！\r\n",{
                   title: '提示框',				
   				icon:0,								
             }); 
              
		    num++;
           return false;            
         } 
		 
		  if(num>0){  return false;}	 	
         else{
       	  
       	  $("#updateForm").submit();
				layer.close(index);	
		  }		  		     				
		}
   });
	
}


/*用户详情*/
function member_show(obj){
	$("#cusdetails").find(".cusinfo1").html($(obj).parent("td").find("#cusinfo1").html());
	$("#cusdetails").find(".cusinfo1").html($(obj).parent("td").find("#cusinfo1").html());
	$("#cusdetails").find(".cusinfo2").html($(obj).parent("td").find("#cusinfo2").html());
	$("#cusdetails").find(".cusinfo3").html($(obj).parent("td").find("#cusinfo3").html());
	$("#cusdetails").find(".cusinfo4").html($(obj).parent("td").find("#cusinfo4").html());
	$("#cusdetails").find(".cusinfo5").html($(obj).parent("td").find("#cusinfo5").html());
	$("#cusdetails").find(".cusinfo6").html($(obj).parent("td").find("#cusinfo6").html());
	$("#cusdetails").find(".cusinfo7").html($(obj).parent("td").find("#cusinfo7").html());
	$("#cusdetails").find(".cusinfo8").html($(obj).parent("td").find("#cusinfo8").html());
	var index = layer.open({
        type: 1,     
        title: '留言信息',
		maxmin: true, 
		shadeClose:false,
        area : ['600px' , ''],
        content:$('#cusdetails'),
		btn:['确定','取消'],
		yes: function(index, layero){
			  layer.close(index);      		  
		  
	   }
	});	
};


/*checkbox激发事件*/
$('#checkbox').on('click',function(){
	if($('input[name="checkbox"]').prop("checked")){
		 $('.Reply_style').css('display','block');
		}
	else{
		
		 $('.Reply_style').css('display','none');
		}	
	});

	
</script>

<script type="text/javascript">
jQuery(function($) {
	var oTable1 = $('#sample-table').dataTable( {
	"aaSorting": [[ 1, "desc" ]],//默认第几个排序
	"bStateSave": true,//状态保存
	"aoColumnDefs": [
	  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
	  {"orderable":false,"aTargets":[0,2,4,6,9,10]}// 制定列不参与排序
	] } );
		$('table th input:checkbox').on('click' , function(){
			var that = this;
			$(this).closest('table').find('tr > td:first-child input:checkbox')
			.each(function(){
				this.checked = that.checked;
				$(this).closest('tr').toggleClass('selected');
			});
				
		});	
		$('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
		function tooltip_placement(context, source) {
			var $source = $(source);
			var $parent = $source.closest('table')
			var off1 = $parent.offset();
			var w1 = $parent.width();
	
			var off2 = $source.offset();
			var w2 = $source.width();
	
			if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
			return 'left';
		}
	});
</script>
